﻿/**
*    @file:    mainservice.cpp
*    @brief:
*    @author:  sanshi522@163.com
*    @date:    2024-10-31  20:19
*/

#include "mainservice.h"
#include <QDebug>

MainService::MainService(int argc, char *argv[])
    : QtService<QCoreApplication>(argc, argv, "EmqxService")
{
    setServiceDescription(QString("MQTT服务@中科星光-颜磊"));
    setServiceFlags(QtServiceBase::CanBeSuspended);
    setStartupType(QtServiceController::AutoStartup);
    isStart = false;
}

MainService::~MainService()
{
    if (isStart)
        stop();
}

void MainService::start()
{
    qInfo() << QString("服务启动...");
    serviceCenter = new ServiceCenter();
    isStart = true;
}

void MainService::stop()
{
    qInfo() << QString("服务停止...");
    delete serviceCenter;
    isStart = false;
}

void MainService::pause()
{
    qInfo() << QString("暂停");
}

void MainService::resume()
{
    qInfo() << QString("继续");
}
